﻿@{
    Bundle("jquery_validate");
}
           
@foreach(var i in Model.Items)
{
    <fieldset class="groupbox">
        <legend>
            <ul class="bar inlinebar">
                <li><a class="confirm" href="@Url.Action(Loc.Act("RemoveItem").Ctrl("ShoppingCart").Set(new
                {
                    cartID = JDM.Int32(Model.EntityID), 
                    itemID = JDM.Int32(i.EntityID), 
                    quantity = JDM.Decimal(i.Quantity)
                }))">x</a></li>
            </ul>
        </legend>
        <section>
            <form id="@ID("form_{0}", JDM.Int32(i.EntityID))" action="#">
                <table>
                    <tr>
                        <td>
                            <a href="@Url.Action(Loc.Act("Edit").Ctrl("SalesItem").Set(new
                            {
                                id = JDM.Int32(i.SalesItem.EntityID)
                            }))" class="ui-icon ui-icon-extlink"></a>
                            <label>@T(Res.Name("SalesItem"))</label>
                        </td>
                        <td>
                            <input type="text" readonly value="@JDM.Int32(i.SalesItem.EntityID)" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>@T(Res.Name("Quantity"))</label>
                        </td>
                        <td>
                            <input type="text" readonly value="@Svc.Numeric((decimal)JDM.Decimal(i.Quantity))" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>@T(Res.Name("Price"), JDM.String(Svc.Localization.Currency.Code))</label>
                        </td>
                        <td>
                            <input type="text" readonly value="@Svc.Price((decimal)JDM.Decimal(i.Price))" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>@T(Res.Name("Total"), JDM.String(Svc.Localization.Currency.Code))</label>
                        </td>
                        <td>
                            <input type="text" readonly value="@Svc.Price((decimal)JDM.Decimal(i.Total))" />
                        </td>
                    </tr>
                </table>
            </form>
        </section>
        <header>
            <h3>@T(Res.Name("Options"))</h3>
        </header>
        <section>
        @{
            Html.RenderPartial("_ItemOptions", (object)i);
        }
        </section>
    </fieldset>
}
<fieldset class="groupbox">
    <section>
        <script type="text/javascript">
            jQuery(document).ready(function () {
                jQuery('@ID("#form_new")').validate({
                    rules: {
                        salesItemID: {
                            required: true,
                            digits: true
                        },
                        price: {
                            required: true
                        },
                        quantity: {
                            required: true
                        }
                    }
                });
            });
        </script>
        <form id="@ID("form_new")" action="@Url.Action(Loc.Act("PutItem").Ctrl("ShoppingCart"))" method="post">
            <input type="hidden" name="cartID" value="@JDM.Int32(Model.EntityID)" />
            <input type="hidden" name="flags" value="None" />
            <table>
                <tr>
                    <td>
                        <label>@T(Res.Name("SalesItem"))</label>
                    </td>
                    <td>
                        <input type="text" name="salesItemID" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>@T(Res.Name("Quantity"))</label>
                    </td>
                    <td>
                        <input type="text" name="quantity" value="@Svc.Numeric(1)" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>@T(Res.Name("Price"), JDM.String(Svc.Localization.Currency.Code))</label>
                    </td>
                    <td>
                        <input type="text" name="price" value="@Svc.Price(Decimal.Zero)" />
                    </td>
                </tr>
            </table>
            <ul class="bar toolbar">
                <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
            </ul>
        </form>
    </section>
</fieldset>